const {
    getTaskUrl,
} = require('./ti_config');

const {
    httpPost,
    logger,
} = require('./util');

//读取任务列表
exports.readTask = async (pageNum=1, limit=200) => {
    let tasks = null;
    try {
        const retStr = await httpPost(getTaskUrl, 'limit='+limit+'&page='+pageNum);
        const ret = JSON.parse(retStr);
        if (ret.status == 200) {
            if (ret.data.total > 0) {
                tasks = ret.data.data;
            } else {
                return logger('无任务');
            }
        } else {
            return logger('读取任务出错');
        }
    } catch(e) {
        return logger('读取任务异常', e);
    }
    return tasks;
}
